from google.appengine.ext import ndb

# use time as key id may speedup the query.

class Account(ndb.Model):
    # email is the key, format as email*random for guest
    nickname = ndb.StringProperty()
    purviews = ndb.StringProperty(repeated=True) # at least anonymous, None for guest
    site = ndb.StringProperty()
    message = ndb.StringProperty()
    note = ndb.StringProperty()
    bad_guy = ndb.BooleanProperty(default=False)

class Article(ndb.Model):
    # date time is the key
    title = ndb.StringProperty(required=True)
    language = ndb.StringProperty() # hk,en,tw
    summary = ndb.TextProperty()
    body = ndb.TextProperty()
    categories = ndb.StringProperty(repeated=True)
    tags = ndb.StringProperty(repeated=True)
    purview = ndb.StringProperty() # None, tf,gf,non_work,unibdy...
    counter = ndb.IntegerProperty(default=0)

class Reply(ndb.Model):
    # date time is the key, and key's father is model 'Article'
    when = ndb.IntegerProperty() # duplicated, used only for 'Recent Comments'
    body = ndb.TextProperty()
    author_key = ndb.KeyProperty(kind=Account) # references Account
    approval = ndb.BooleanProperty(default=False)

"""
class Diary(ndb.Model):
    # date time is the key
    title = ndb.StringProperty(required=True)
    body = ndb.TextProperty()
"""
